/*
 * Created on 2005-6-11
 *
 * To change the template for this generated file go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
package leeon.util;

import java.io.File;
import java.io.FileInputStream;
import java.util.Enumeration;
import java.util.Properties;

/**
 * @author Administrator
 *
 * To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
public class PropertyLoader {

	public static void main(String[] args) throws Exception {
		PropertyLoader pl = PropertyLoader.newInstance("downloader.conf");
		System.out.println(pl.getProperty("url"));
		System.out.println(pl.getProperty("proxy"));
	}
	
	
	private Properties pro = null;
	
	private PropertyLoader() {}
	
	private PropertyLoader(String path) throws Exception {
		pro = new Properties();
		File file = new File(path);
		FileInputStream fis = new FileInputStream(file);
		pro.load(fis);
	}
	
	public static PropertyLoader newInstance(String path) throws Exception {
		return new PropertyLoader(path);
	}
	/**
	 * @param arg0
	 * @return
	 */
	public String getProperty(String arg0) {
		return pro.getProperty(arg0);
	}

	/**
	 * @param arg0
	 * @param arg1
	 * @return
	 */
	public String getProperty(String arg0, String arg1) {
		return pro.getProperty(arg0, arg1);
	}

	/**
	 * @return
	 */
	public Enumeration propertyNames() {
		return pro.propertyNames();
	}

}
